package com.notelapierdas.data;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import android.util.Log;

public class SoapManager {

	private static final String NAMESPACE = "urn:Magento";
    private static final String URL = "http://test.notelapierdas.com.uy/index.php/api/v2_soap/?wsdl";
    
    public void a(){
    	try {
    		 
            SoapSerializationEnvelope env = new SoapSerializationEnvelope(
                    SoapEnvelope.VER11);
 
            env.dotNet = false;
            env.xsd = SoapSerializationEnvelope.XSD;
            env.enc = SoapSerializationEnvelope.ENC;
 
            SoapObject request = new SoapObject(NAMESPACE, "login");
 
            request.addProperty("username", "mariana.ardoino");
            request.addProperty("apiKey", "fgY56ei");
 
            env.setOutputSoapObject(request);
 
            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
 
            androidHttpTransport.call("", env);
            Object result = env.getResponse();
 
            Log.d("sessionId", result.toString());
 
            //making call to get list of customers
 
            String sessionId = result.toString();
 
            request = new SoapObject(NAMESPACE, "catalogProductEntity");
            request.addProperty("sessionId",sessionId );
 
            env.setOutputSoapObject(request);
            androidHttpTransport.call("", env);
 
            result = env.getResponse();
 
            Log.d("catalogProductEntity", result.toString());
 
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
	
}
